<?php 
	$_moduleName = $controllerName = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
	$_controllerName = $controllerName = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
	$_actionName = $controllerName = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
	
	//Define all menu options
	switch($_moduleName) {
		//USER
		case 'user':
			$options = array(
				array('title' => 'Usuários', 'options' => array(
					array('controller'=>'user','action'=>'list','label'=>'Gerenciar usuários'),
					array('controller'=>'user','action'=>'add','label'=>'Inserir novo usuário'),
					)
				),
			);
			break;
				
				
		//CLIENT
		case 'client':
			$options = array(
				array('title' => 'Pessoa Física', 'options' => array(
					array('controller'=>'personal','action'=>'list','label'=>'Gerenciar pessoa física'),
					array('controller'=>'personal','action'=>'add','label'=>'Inserir nova pessoa física'),
					)
				),
				array('title' => 'Pessoa Jurídica', 'options' => array(
					array('controller'=>'company','action'=>'list','label'=>'Gerenciar pessoa jurídica'),
					array('controller'=>'company','action'=>'add','label'=>'Inserir nova pessoa jurídica'),
					)
				),
			);
			break;
			
			
		//ADMIN
		case 'admin':
			$options = array(
			
				array('title' => 'Cadastros básicos', 'options' => array(
					array('controller'=>'organ','action'=>'list','label'=>'Gerenciar orgãos'),
					array('controller'=>'sector','action'=>'list','label'=>'Gerenciar setores'),
					array('controller'=>'subject','action'=>'list','label'=>'Gerenciar assuntos'),
					array('controller'=>'typeprotocol','action'=>'list','label'=>'Gerenciar tipos de protocolo'),
					array('controller'=>'craft','action'=>'list','label'=>'Gerenciar cargos'),
					)
				),				
			);
			break;		
			
		case 'error':
		case 'default':
			return false;
			break;
	}
	
	//Render the menu
	if(isset($options)) {
		foreach($options as $menu) {
			echo '<div class="submenublock">';
				echo '<div class="submenublock-title">'.$menu['title'].'</div>';
				echo '<div class="submenublock-text">';
				echo '<ul>';
					foreach($menu['options'] as $option) {
							if($_actionName==$option['action'] && $_controllerName == $option['controller']) {
								echo '<li><a href="'.$this->url(array('module' => $_moduleName, 'controller'=> $option['controller'],'action'=> $option['action'],'id'=> $option['id']), null, true).'"><span>'.$option['label'].'</span></a></li>';
							} else {
								echo '<li><a href="'.$this->url(array('module' => $_moduleName, 'controller'=> $option['controller'],'action'=> $option['action']), null, true).'">'.$option['label'].'</a></li>';	
							}
					}
				echo '</ul>';
				echo '</div>';
			echo '</div>';
			
		}
	}
?>
